/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.agenda.model.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Ronildo
 */
@Entity
@Table(name = "AM_TB_MEDI_PLAN_SAUD")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AmTbMediPlanSaud.findAll", query = "SELECT a FROM AmTbMediPlanSaud a"),
    @NamedQuery(name = "AmTbMediPlanSaud.findByCdPlanSaud", query = "SELECT a FROM AmTbMediPlanSaud a WHERE a.amTbMediPlanSaudPK.cdPlanSaud = :cdPlanSaud"),
    @NamedQuery(name = "AmTbMediPlanSaud.findByCdMedi", query = "SELECT a FROM AmTbMediPlanSaud a WHERE a.amTbMediPlanSaudPK.cdMedi = :cdMedi"),
    @NamedQuery(name = "AmTbMediPlanSaud.findByDtInicVige", query = "SELECT a FROM AmTbMediPlanSaud a WHERE a.amTbMediPlanSaudPK.dtInicVige = :dtInicVige"),
    @NamedQuery(name = "AmTbMediPlanSaud.findByDtFimVige", query = "SELECT a FROM AmTbMediPlanSaud a WHERE a.dtFimVige = :dtFimVige")})
public class AmTbMediPlanSaud implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected AmTbMediPlanSaudPK amTbMediPlanSaudPK;
    @Column(name = "DT_FIM_VIGE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dtFimVige;
    @JoinColumn(name = "CD_PLAN_SAUD", referencedColumnName = "CD_PLAN_SAUD", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private AmTbPlanSaud amTbPlanSaud;
    @JoinColumn(name = "CD_MEDI", referencedColumnName = "CD_MEDI", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private AmTbMedi amTbMedi;

    public AmTbMediPlanSaud() {
    }

    public AmTbMediPlanSaud(AmTbMediPlanSaudPK amTbMediPlanSaudPK) {
        this.amTbMediPlanSaudPK = amTbMediPlanSaudPK;
    }

    public AmTbMediPlanSaud(int cdPlanSaud, int cdMedi, Date dtInicVige) {
        this.amTbMediPlanSaudPK = new AmTbMediPlanSaudPK(cdPlanSaud, cdMedi, dtInicVige);
    }

    public AmTbMediPlanSaudPK getAmTbMediPlanSaudPK() {
        return amTbMediPlanSaudPK;
    }

    public void setAmTbMediPlanSaudPK(AmTbMediPlanSaudPK amTbMediPlanSaudPK) {
        this.amTbMediPlanSaudPK = amTbMediPlanSaudPK;
    }

    public Date getDtFimVige() {
        return dtFimVige;
    }

    public void setDtFimVige(Date dtFimVige) {
        this.dtFimVige = dtFimVige;
    }

    public AmTbPlanSaud getAmTbPlanSaud() {
        return amTbPlanSaud;
    }

    public void setAmTbPlanSaud(AmTbPlanSaud amTbPlanSaud) {
        this.amTbPlanSaud = amTbPlanSaud;
    }

    public AmTbMedi getAmTbMedi() {
        return amTbMedi;
    }

    public void setAmTbMedi(AmTbMedi amTbMedi) {
        this.amTbMedi = amTbMedi;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (amTbMediPlanSaudPK != null ? amTbMediPlanSaudPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AmTbMediPlanSaud)) {
            return false;
        }
        AmTbMediPlanSaud other = (AmTbMediPlanSaud) object;
        if ((this.amTbMediPlanSaudPK == null && other.amTbMediPlanSaudPK != null) || (this.amTbMediPlanSaudPK != null && !this.amTbMediPlanSaudPK.equals(other.amTbMediPlanSaudPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.agenda.model.entity.AmTbMediPlanSaud[ amTbMediPlanSaudPK=" + amTbMediPlanSaudPK + " ]";
    }
    
}
